from django.shortcuts import render
from django.views import View
from QQLoginTool.QQtool import OAuthQQ
from django.contrib.auth import settings
from django.http import JsonResponse
from meiduo_mall.libs.response_code import RETCODE
class OAuthURLView(View):
    def get(self,request):

        next_url = request.GET.get('next','/')

        #在settings中填入QQ配置信息
        oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                        client_secret=settings.QQ_CLIENT_SECRET,
                        redirect_uri=settings.QQ_REDIRECT_URI,
                        state=next_url)

        login_url = oauth.get_qq_url()

        return JsonResponse({'code':RETCODE.OK,'errmsg':'ok','login_url':login_url})


# Create your views here.
